import 'package:flutter/material.dart';

/// Create by kyluzoi
/// Date: 2021-08-25
///
/// Description: Hero 路由 转场动画

class FadeRoute<T> extends PageRouteBuilder<T> {
  final Widget page;

  FadeRoute({required this.page,RouteSettings? settings,})
      : super(
    settings: settings,
    pageBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        ) =>
    page,
    transitionsBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        Widget child,
        ) {
      final tween = Tween(begin: 0.5, end: 1.0)
          .chain(CurveTween(curve: Curves.linear));
      return FadeTransition(
        opacity: animation.drive(tween),
        child: child,
      );
    },
  );
}
